# -*- coding: utf-8 -*-
"""
Created on Tue May  9 16:23:40 2023

@author: lenovo
"""

from osgeo import gdal
import glob

name=['水源涵养','土壤保持','洪水调蓄','空气净化','水质净化','固碳价值','气候调节',
      '负氧离子','释氧价值','储量碳价值','水资源']

path=r'H:\company\公司项目\陕西\商洛\data'

for na in name:
    # 设置输入文件路径
    input_files = glob.glob(path+'\\GEP\\'+na+'*.tif')
    # 设置输出文件路径
    output_file = path+'\\merged\\'+na+'.tif'
    
    inputrasfile=[]
    for fn in input_files:
        infn=gdal.Open(fn, gdal.GA_ReadOnly)
        inputProj1 = infn.GetProjection()
        inputrasfile.append(infn)
        
    
    options=gdal.WarpOptions(srcSRS=inputProj1, dstSRS=inputProj1,format='GTiff')
    gdal.Warp(output_file,inputrasfile,options=options)



